#!usr/bin/env python
#coding=utf8

import re

from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Q

from tuangou.models.tuan_models import AppForm, Feedback
from tuangou.common_logic import commutil
    
def save_appform(**kwargs):
    app = AppForm(**kwargs)
    app.save()
    return app

def save_feedback(**kwargs):
    feed = Feedback(**kwargs)
    feed.save()
    return feed 

def get_feedback_list_by_page(page, page_size):
    page, page_size, offset = commutil.get_page_offset(page, page_size)
    feedbacks = Feedback.objects.all()[offset : offset + page_size]

    return feedbacks

def get_feedback_count():
    return Feedback.objects.count()

def del_feedback_by_id(id):
    Feedback.objects.filter(id = id).delete()

def get_appform_list_by_page(page, page_size):
    page, page_size, offset = commutil.get_page_offset(page, page_size)
    appforms = AppForm.objects.all()[offset : offset + page_size]

    return appforms

def get_appform_count():
    return AppForm.objects.count()


def del_appform_by_id(id):
    AppForm.objects.filter(id = id).delete()